package com.lej.home.pay

import com.lej.core.base.BaseModel
import com.lej.core.base.BaseViewModel
import com.lej.dataservice.club.http.base.getBody
import com.lej.dataservice.club.http.request
import com.lej.home.http.homeApiService

/**
 *  author: cjq
 *  date  : 2022/7/18 0018
 *  desc  :
 */
class NftPayVM : BaseViewModel<BaseModel>() {
    var nftId = -1
    fun getPayDetail() = request { homeApiService.getPayDetail(nftId) }

    fun createOrder(payInfoId: Int, price: Int, addPrice: Int) = request {
        homeApiService.createOrder(
            getBody(
                "pay_info_id" to payInfoId,
                "quantity" to price,
                "bid_price" to addPrice
            )
        )
    }

    fun createBuyOrder(payInfoId: Int, num: Int) = request {
        homeApiService.createBuyOrder(getBody("pay_info_id" to payInfoId, "quantity" to num))
    }

    fun orderPay(orderId: Int) = request {
        homeApiService.orderPay(
            getBody(
                "order_id" to orderId,
                "pay_platform" to 1, //1 微信 2 支付宝
                "pay_type" to "app"
            )
        )
    }


    fun buyPay(orderId: Int) = request {
        homeApiService.buyPay(
            getBody(
                "order_id" to orderId,
                "pay_platform" to 1, //1 微信 2 支付宝
                "pay_type" to "app"
            )
        )
    }
}